package br.com.io.streams;

import java.io.DataOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class EscrevendoPrimitivos {
	public static void main(String[] args) {
		String barra = File.separator;
		try {
			File dir = new File("stream" + barra + "DataOutPut");
			dir.mkdirs();
			
			File f = new File(dir,"primitives.data");
				
			
			FileOutputStream outputFile = new FileOutputStream(f);
			DataOutputStream outputStream = new DataOutputStream(outputFile);

			outputStream.writeBoolean(false);
			outputStream.writeChar('A'); // int written as Unicode char
			outputStream.writeByte(Byte.MAX_VALUE); // int written as 8-bits
													// byte
			outputStream.writeShort(Short.MIN_VALUE); // int written as 16-bits
														// short
			outputStream.writeInt(Integer.MAX_VALUE);
			outputStream.writeLong(Long.MIN_VALUE);
			outputStream.writeFloat(Float.MAX_VALUE);
			outputStream.writeDouble(Math.PI);
			outputStream.close();

		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
